from dataclasses import field
from typing import Any

from .http_code import HttpCode


class CustomException(Exception):
    code: HttpCode = HttpCode.FAILED
    message: str = ""
    data: Any = field(default_factory=dict)

    def __init__(self, message: str, data: Any = None):
        self.message = message
        self.data = data


class FailedException(CustomException):
    pass


class UnauthorizedException(CustomException):
    code = HttpCode.UNAUTHORIZED


class NotFoundException(CustomException):
    code = HttpCode.NOT_FOUND


class ForbiddenException(CustomException):
    code = HttpCode.FORBIDDEN


class ValidationException(CustomException):
    code = HttpCode.VALIDATION_FAILED
